{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Most examples work across multiple plotting backends, this example is also available for:\n",
    "\n",
    "* [Matplotlib - dropdown_economic](../matplotlib/dropdown_economic.ipynb)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import holoviews as hv\n",
    "from holoviews import opts, dim\n",
    "hv.extension('bokeh')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Declaring data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "macro_df = pd.read_csv('http://assets.holoviews.org/macro.csv', '\\t')\n",
    "key_dimensions   = [('year', 'Year'), ('country', 'Country')]\n",
    "value_dimensions = [('unem', 'Unemployment'), ('capmob', 'Capital Mobility'),\n",
    "                    ('gdp', 'GDP Growth'), ('trade', 'Trade')]\n",
    "macro = hv.Table(macro_df, key_dimensions, value_dimensions)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Plot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "gdp_curves = macro.to.curve('Year', 'GDP Growth')\n",
    "gdp_unem_scatter = macro.to.scatter('Year', ['GDP Growth', 'Unemployment'])\n",
    "annotations = hv.Arrow(1973, 8, 'Oil Crisis', 'v') * hv.Arrow(1975, 6, 'Stagflation', 'v') *\\\n",
    "hv.Arrow(1979, 8, 'Energy Crisis', 'v') * hv.Arrow(1981.9, 5, 'Early Eighties\\n Recession', 'v')\n",
    "\n",
    "(gdp_curves * gdp_unem_scatter* annotations).opts(\n",
    "    opts.Curve(color='k'), \n",
    "    opts.Scatter(cmap='Blues', color='Unemployment', \n",
    "                 line_color='k', size=dim('Unemployment')*1.5),\n",
    "    opts.Text(text_font_size='13px'),\n",
    "    opts.Overlay(height=400, show_frame=False, width=700))"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
